<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<title>Test that data: URLs fail registerProtocolHandler checks</title>
<body>
<iframe id='frame'></iframe>

<script>
setup({single_test: true});

const frameSrc =
`<html>
<head>
<script>
try {
  navigator.registerProtocolHandler('web+test',
                                    location.href + '?%s',
                                    'Test handler');
  window.parent.postMessage('rph succeeded', '*');
} catch (e) {
  window.parent.postMessage('rph failed: ' + e.message, '*');
}
<\/script>
<\/head>
<body>
Test page
<\/body>
<\/html>
`

window.addEventListener('message', (msg) => {
  assert_equals(msg.data,
  'rph failed: navigator.registerProtocolHandler is not a function');
  done();
});

document.getElementById('frame').src = 'data:text/html,' + frameSrc;
</script>
</body>
